package co.edu.usbcali.sgi.modelo.dto;

import co.edu.usbcali.sgi.modelo.Rubro;
import co.edu.usbcali.sgi.presentation.backEndBeans.RubroView;

import java.io.Serializable;

import java.util.Date;

import javax.faces.event.ActionEvent;


/**
*
*
* @author Zathura Code Generator http://code.google.com/p/zathura
*
*/
public class RubroDTO implements Serializable {
    private static final long serialVersionUID = 1L;
    private String rubNombre;
    private String rubCod;
    private boolean rowSelected = false;
    private RubroView rubroView;
    private Rubro rubro;

    public Rubro getRubro() {
        return rubro;
    }

    public String listener_update(ActionEvent e) {
        try {
            rubroView.action_modifyWitDTO(((rubCod == null) ||
                rubCod.equals("")) ? null : new String(rubCod),
                ((rubNombre == null) || rubNombre.equals("")) ? null
                                                              : new String(
                    rubNombre));
            rowSelected = !rowSelected;
        } catch (Exception ex) {
            return "";
        }

        return "";
    }

    public void listener_cancel(ActionEvent e) {
        rubCod = rubro.getRubCod().toString();
        rubNombre = (rubro.getRubNombre() != null)
            ? rubro.getRubNombre().toString() : null;
        rowSelected = !rowSelected;
    }

    /**
    * <p>Bound to commandLink actionListener in the ui that renders/unrenders
        * the Customer details for editing.</p>
        */
    public void toggleSelected(ActionEvent e) {
        rubCod = rubro.getRubCod().toString();
        rubNombre = (rubro.getRubNombre() != null)
            ? rubro.getRubNombre().toString() : null;
        rowSelected = !rowSelected;
    }

    public void setRubro(Rubro rubro) {
        this.rubro = rubro;
    }

    public RubroView getRubroView() {
        return rubroView;
    }

    public void setRubroView(RubroView rubroView) {
        this.rubroView = rubroView;
    }

    public String getRubNombre() {
        return rubNombre;
    }

    public void setRubNombre(String rubNombre) {
        this.rubNombre = rubNombre;
    }

    public String getRubCod() {
        return rubCod;
    }

    public void setRubCod(String rubCod) {
        this.rubCod = rubCod;
    }

    public boolean isRowSelected() {
        return rowSelected;
    }

    public void setRowSelected(boolean rowSelected) {
        this.rowSelected = rowSelected;
    }
}
